<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<button type="button" id="btn">创建推送消息</button>
		
		<p id="message">push test success</p>
	
		<script>
			document.addEventListener( "plusready", function(){
			    message = document.getElementById("message");
			    btn = document.getElementById("btn");
			    
			    btn.addEventListener('click',function(){
			    	setTimeout(function(){
			    		plus.push.createMessage('delay msg sended')
			    	},5000)
			    })
			    // 监听点击消息事件
			    plus.push.addEventListener( "click", function( msg ) {
			    	
			        // 判断是从本地创建还是离线推送的消息
			        switch( msg.payload ) {
			            case "LocalMSG":
			                outSet( "点击本地创建消息启动：" );
			            break;
			            default:
			                outSet( "点击离线推送消息启动：");
			            break;
			        }
			        // 提示点击的内容
			        plus.ui.alert( msg.content );
			        // 处理其它数据
			        logoutPushMsg( msg );
			    }, false );
			    // 监听在线消息事件
			    plus.push.addEventListener( "receive", function( msg ) {
			        if ( msg.aps ) {  // Apple APNS message
			            console.log( "接收到在线APNS消息：" );
			        } else {
			        	plus.device.beep();
			        	plus.device.setWakelock(true)
			            console.log( "接收到在线透传消息：" );
			        }
			        console.log( msg );
			    }, false );
			}, false );
		</script>
	</body>
</html>
